<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
	<head>
		<title>regist</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="css/style.css" />
	</head>
	<body>
		<div id="wrap">
			<div id="top_content">
					<div id="header">
						<div id="rightheader">
							<p>
								<a href="javascript:;" v-on:click="login">已有账号直接登录</a>
								<br />
							</p>
						</div>
						<div id="topheader">
							<h1 id="title">
								<a href="#">main</a>
							</h1>
						</div>
						<div id="navigation">
						</div>
					</div>
				<div id="content">
					<p id="whereami">
					</p>
					<h1>注册</h1>
					<form action="login.html" method="post">
						<table cellpadding="0" cellspacing="0" border="0"
							class="form_table">
							<tr>
								<td valign="middle" align="right">
									用户名:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" v-model="user.username" />
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									真实姓名:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" v-model="user.realname" />
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									密码:
								</td>
								<td valign="middle" align="left">
									<input type="password" class="inputgri" v-model="user.password" />
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									性别:
								</td>
								<td valign="middle" align="left"><!--value="男"-->
									男
									<input type="radio" class="inputgri" v-model="user.sex" value="男" checked="checked"/>
									女
									<input type="radio" class="inputgri" v-model="user.sex" value="女"/>
								</td>
							</tr>
							
							<tr>
								<td valign="middle" align="right">
									验证码:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" v-model="code" />
								</td>
								<td>
									<img id="num" v-bind:src="url"/>
									<a href="javascript:;" v-on:click="getSrc">换一张</a>
								</td>
							</tr>
						</table>
						<p><!--value="Submit &raquo;"-->
							<input type="button" class="button" v-on:click="register" VALUE="提交数据"/>
						</p>
					</form>

				</div>
			</div>
			<div id="footer">
				<div id="footer_bg">
				ABC@126.com
				</div>
			</div>
		</div>
	</body>
</html>
<script src="/emsvue/js/vue.js"></script>
<script src="/emsvue/js/axios.min.js"></script>
<script>
	var app = new Vue({
		el:"#wrap",
		data:{
			url:"",
			user:{
				sex:"男"
			},
			code:"",
		},
		methods:{
			//登录页面跳转
			login(){
				location.href="http://localhost:8990/emsvue/login.html";
			},
			//用来更换验证码实现
			getImg(){
				this.getSrc();
			},
			//获取验证码的
			getSrc(){
				var  _this = this;
				axios.get("http://localhost:8990/emsvue/user/getImage?time="+Math.random()).then(res=>{
					_this.url = res.data;

				});
			},
			//用来注册用户信息register
			register(){
				axios.post("http://localhost:8990/emsvue/user/register?code="+this.code,this.user).then(res=>{
					console.log("你妹的进来了.....................");
					console.log(res.data);
					if(res.data.state){
						alert(res.data.msg+",点击确定跳转至登录页面!");/* 只有点击确定,alert()方法才算执行完毕 */
						location.href="http://localhost:8990/emsvue/login.html";
					}else{
						alert(res.data.msg);
					}
				});
			},
		},
		created(){
			//获取验证码
			this.getSrc();
		}
	})
</script>
